<!--
 * @Author: 郭招娣 10615594+guo-zhaodi@user.noreply.gitee.com
 * @Date: 2022-08-23 14:43:40
 * @LastEditors: 郭招娣 10615594+guo-zhaodi@user.noreply.gitee.com
 * @LastEditTime: 2022-08-27 10:02:51
 * @FilePath: \后端管理系统\app\src\views\Goods\GoodsTable.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <div>
    <el-table :data="tableData" style="width: 100%">
      <el-table-column fixed prop="goods_name" label="商品名称">
      </el-table-column>
      <el-table-column prop="goods_price" label="商品价格（元）">
      </el-table-column>
      <el-table-column prop="goods_weight" label="商品重量">
      </el-table-column>
      <el-table-column prop="add_time" label="创建时间">
        <template v-slot="scope">
          {{ scope.row.add_time | newdata }}
        </template>
      </el-table-column>
      <el-table-column fixed="right" label="操作" width="120">
        <template slot-scope="scope">
          <el-button
            @click.native.prevent="deleteRow(scope.$index, tableData)"
            type="text"
            size="small"
          >
            移除
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="goodsObj.pagenum"
      :page-sizes="[100, 200, 300, 400]"
      :page-size="goodsObj.pagesize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
    >
    </el-pagination>
  </div>
</template>

<script>
export default {
  props: {
    tableData: {
      type: Array,
      default: () => {
        return [];
      },
    },
    goodsObj: {
        type:Object,
        default:()=>{
            return {
                query: '',
                pagenum: 1,
                pagesize: 2
            }
        }
    },
    total:{
        type:Number,
        default:0
    },
  },
  data() {
    return {};
  },
  methods: {
    handleSizeChange(val) {
        this.$emit('page-change', {
            type:'size',
            val
        })
    },
    handleCurrentChange(val) {
      this.$emit('page-change', {
        type: 'num',
        val
      });
    },
  },
};
</script>